package com.stroke.entity;

import com.stroke.graphics.Animation;

import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.geom.Point2D;

/**
 * Author: Igor Bubelov
 * Date: 3/5/11 8:14 PM
 */
public abstract class AbstractEntity implements Entity {
    private Point2D position = new Point.Double();
    private double speed;
    private double direction;

    private boolean visible = true;
    private Animation animation;
    private Point origin = new Point();

    public Point2D getPosition() {
        return position;
    }

    public void setPosition(Point2D position) {
        this.position = position;
    }

    public void shift(double x, double y) {
        position.setLocation(position.getX() + x, position.getY() + y);
    }

    public void moveTo(double x, double y) {
        position.setLocation(x, y);
    }

    public double getSpeed() {
        return speed;
    }

    public void setSpeed(double speed) {
        this.speed = speed;
    }

    public double getDirection() {
        return direction;
    }

    public void setDirection(double direction) {
        this.direction = direction;
    }

    public void step() {
        if (speed != 0) {
            double deltaX = speed * Math.cos(Math.toRadians(direction));
            double deltaY = speed * Math.sin(Math.toRadians(direction));

            shift(deltaX, -deltaY);
        }
    }

    /////

    public boolean isVisible() {
        return visible;
    }

    public void setVisible(boolean visible) {
        this.visible = visible;
    }

    public Image getImage() {
        return animation.getImage();
    }

    public void setImage(Animation image) {
        this.animation = image;
    }

    public Point getOrigin() {
        return origin;
    }

    public void setOrigin(Point origin) {
        this.origin = origin;
    }

    /////

    public void keyTyped(KeyEvent e) { }

    public void keyPressed(KeyEvent e) { }

    public void keyReleased(KeyEvent e) { }

    /////

    public void mouseClicked(MouseEvent e) { }

    public void mousePressed(MouseEvent e) { }

    public void mouseReleased(MouseEvent e) { }

    public void mouseEntered(MouseEvent e) { }

    public void mouseExited(MouseEvent e) { }

    /////

    public void mouseDragged(MouseEvent e) { }

    public void mouseMoved(MouseEvent e) { }

    /////

    public void mouseWheelMoved(MouseWheelEvent mouseWheelEvent) { }
}
